/**
 * Created by Administrator on 2016/7/1.
 */
"use strict";
swan_pc
    .controller("AgendaController",function($scope,Clip,TimeExchange,$state,CompanyClipSearch){
        $scope.inputClipName=null;
        $scope.predicate = 'id';
        $scope.reverse = true;
        $scope.page = 1;
        Clip.query({page: $scope.page - 1, size: 500, sort: [$scope.predicate + ',' + ($scope.reverse ? 'asc' : 'desc'), 'id']},
            function(result, headers) {
                $scope.totalItems = headers('X-Total-Count');
                $scope.allClips = result;
            });
        $scope.NeedToDeleteClip=null;
        $scope.GoToDelete=function(){
            Clip.delete({clipid:$scope.NeedToDeleteClip},function(result){
                swal("Delete Success!");
            },
            function(result){
                swal("Delete Error!!");
                angular.forEach(result,function(data,index,array){
                    console.log(index+" "+data);
                })
            })
        }
        /*$scope.search=function(){
            //console.log("run");
            $scope.clips=[];
            angular.forEach($scope.allClips, function (data, index, array){
                if($scope.inputClipName!=null){
                    var flag=data.name.indexOf($scope.inputClipName);
                    //console.log(data.name+" "+$scope.inputClipName +" "+flag);
                    if(flag>=0){
                        //console.log("push is run");
                        $scope.clips.push(data);
                    }
                }
            })
            console.log($scope.clips);
        }*/
        /*$scope.ShowAll=function(){
            $scope.clips=$scope.allClips;
        }*/
        /*$scope.CompanyClip=[];
        CompanyClipSearch.companyClip(1,0,function(callback){
            $scope.CompanyClip=callback.data;
        });
        //console.log("SearchResult:"+CompanyClipSearch.companyClip(1,0));
        console.log($scope.CompanyClip);
        angular.forEach($scope.CompanyClip,function(data,index,array){
            console.log("CompanyClip:"+data);
        })*/
        //console.log("length:"+$scope.CompanyClip.length);
    })
